package com.itheima.stock.controller.v1;


import com.itheima.stock.annotation.Limiter;
import com.itheima.stock.api.UserControllerAPI;

import com.itheima.stock.enums.CodeEnum;
import com.itheima.stock.exception.Exceptions;
import com.itheima.stock.response.ResponseResult;
import com.itheima.stock.service.UserService;
import com.itheima.stock.vo.CaptchaVO;
import org.springframework.web.bind.annotation.RestController;


//用户接口实现
@RestController
public class UserController implements UserControllerAPI {

    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @Limiter
    @Override
    public ResponseResult<CaptchaVO> captcha() {
        return ResponseResult.ok(userService.captcha());
    }

    @Override
    public String sayHello(String name) {
        Exceptions.cast(CodeEnum.DATA_ERROR);
        return "hello" +name;

    }
}
